package io.shuttle.mbe.api

import io.shuttle.mbe.api.annotation.ChromeMinVersion
import io.shuttle.mbe.api.annotation.PromiseStyleMinVersion
import io.shuttle.mbe.api.types.Value1Function
import io.shuttle.mbe.api.types.Value1ReturnFunction
import io.shuttle.mbe.api.types.Value2ReturnFunction
import io.shuttle.mbe.api.types.Value3Function
import io.shuttle.mbe.api.types.VoidFunction
import io.shuttle.mbe.core.Promise

////////////////////
// Web Request
////////////////////
/**
 * Use the `Browser.webRequest` API to observe and analyze traffic and to intercept, block, or modify requests in-flight.
 *
 * Permissions: "webRequest"
 *
 * Manifest: "host_permissions"
 */
interface WebRequest {
    // The maximum number of times that handlerBehaviorChanged can be called per 10 minute sustained interval. handlerBehaviorChanged is an expensive function call that shouldn't be called often.
    // default is 20
    val MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: Int

    // Needs to be called when the behavior of the webRequest handlers has changed to prevent incorrect handling due to caching. This function call is expensive. Don't call it often.
    @PromiseStyleMinVersion(116)
    abstract fun handlerBehaviorChanged(callback: VoidFunction? = null): Promise<Void>

    // Fired when an extension's proposed modification to a network request is ignored. This happens in case of conflicts with other extensions.
    @ChromeMinVersion(70)
    abstract val onActionIgnored: Events.Event<Value1Function<ActionIgnoredEventDetails>>

    // Fired when an authentication failure is received. The listener has three options: it can provide authentication credentials, it can cancel the request and display the error page, or it can take no action on the challenge. If bad user credentials are provided, this may be called multiple times for the same request. Note, only one of 'blocking' or 'asyncBlocking' modes must be specified in the extraInfoSpec parameter.
    // @param  If "blocking" is specified in the "extraInfoSpec" parameter, the event listener should return an object of this type.
    // @param asyncCallback (response: BlockingResponse) => void
    abstract val onAuthRequired: Events.Event<Value3Function<Value2ReturnFunction<AuthRequiredEventDetails, Value1Function<BlockingResponse>?, BlockingResponse?>, RequestFilter, List<OnAuthRequiredOptions>?>>

    // Fired when a server-initiated redirect is about to occur.
    abstract val onBeforeRedirect: Events.Event<Value3Function<Value1Function<BeforeRedirectEventDetails>, RequestFilter, List<OnBeforeRedirectOptions>?>>

    // Fired when a request is about to occur.
    abstract val onBeforeRequest: Events.Event<Value3Function<Value1ReturnFunction<BeforeRequestEventDetails, BlockingResponse?>, RequestFilter, List<OnBeforeRequestOptions>?>>

    abstract val onBeforeSendHeaders: Events.Event<Value3Function<Value1ReturnFunction<BeforeRedirectEventDetails,BlockingResponse?>, RequestFilter, List<OnBeforeSendHeadersOptions>?>>

    // Fired before sending an HTTP request, once the request headers are available. This may occur after a TCP connection is made to the server, but before any HTTP data is sent.
    abstract val onCompleted: Events.Event<Value3Function<Value1Function<CompletedEventDetails>, RequestFilter, List<OnCompletedOptions>?>>

    // Fired when an error occurs.
    abstract val onErrorOccurred: Events.Event<Value3Function<Value1Function<ErrorOccurredEventDetails>, RequestFilter, List<OnErrorOccurredOptions>?>>

    // Fired when HTTP response headers of a request have been received.
    abstract val onHeadersReceived: Events.Event<Value3Function<Value1ReturnFunction<HeadersReceivedEventDetails, BlockingResponse?>, RequestFilter, List<OnHeadersReceivedOptions>?>>

    // Fired when the first byte of the response body is received. For HTTP requests, this means that the status line and response headers are available.
    abstract val onResponseStarted: Events.Event<Value3Function<Value1Function<ResponseStartedEventDetails>, RequestFilter, List<OnResponseStartedOptions>?>>

    // Fired just before a request is going to be sent to the server (modifications of previous onBeforeSendHeaders callbacks are visible by the time onSendHeaders is fired).
    abstract val onSendHeaders: Events.Event<Value3Function<Value1Function<SendHeadersEventDetails>, RequestFilter, List<OnResponseStartedOptions>?>>

    // Returns value for event handlers that have the 'blocking' extraInfoSpec applied. Allows the event handler to modify network requests.
    data class BlockingResponse(
        // Only used as a response to the onAuthRequired event. If set, the request is made using the supplied credentials.
        var authCredentials: AuthCredentials?,
        // If true, the request is cancelled. This prevents the request from being sent. This can be used as a response to the onBeforeRequest, onBeforeSendHeaders, onHeadersReceived and onAuthRequired events.
        var cancel: Boolean?,
        // Only used as a response to the onBeforeRequest and onHeadersReceived events. If set, the original request is prevented from being sent/completed and is instead redirected to the given URL. Redirections to non-HTTP schemes such as data: are allowed. Redirects initiated by a redirect action use the original request method for the redirect, with one exception: If the redirect is initiated at the onHeadersReceived stage, then the redirect will be issued using the GET method. Redirects from URLs with ws:// and wss:// schemes are ignored.
        var redirectUrl: String?,
        // Only used as a response to the onBeforeSendHeaders event. If set, the request is made with these request headers instead.
        var requestHeaders: List<Header>?,
        // Only used as a response to the onHeadersReceived event. If set, the server is assumed to have responded with these response headers instead. Only return responseHeaders if you really want to modify the headers in order to limit the number of conflicts (only one extension may modify responseHeaders for each request).
        var responseHeaders: List<Header>?,
    )

    // Contains data passed within form data. For urlencoded form it is stored as string if data is utf-8 string and as ArrayBuffer otherwise. For form-data it is ArrayBuffer. If form-data represents uploading file, it is string with filename, if the filename is provided.
    @ChromeMinVersion(66)
    enum class FormDataItem {
        ArrayBuffer,
        string
    }

    data class AuthCredentials(
        var password: String,
        var username: String
    )

    data class Header(
        var name: String,
        // Value of the HTTP header if it can be represented by UTF-8.
        var value: String?,
        // Value of the HTTP header if it cannot be represented by UTF-8, stored as individual byte values (0..255).
        var binaryValue: String?
    )

    @ChromeMinVersion(70)
    enum class IgnoredActionType {
        redirect,
        request_headers,
        response_headers,
        auth_credentials
    }

    @ChromeMinVersion(44)
    enum class OnAuthRequiredOptions {
        // Specifies that the response headers should be included in the event.
        responseHeaders,

        // Specifies the request is blocked until the callback function returns.
        blocking,

        // Specifies that the callback function is handled asynchronously.
        asyncBlocking,

        // Specifies that headers can violate Cross-Origin Resource Sharing (CORS).
        extraHeaders
    }

    @ChromeMinVersion(44)
    enum class OnBeforeRedirectOptions {
        // Specifies that the response headers should be included in the event.
        responseHeaders,

        // Specifies that headers can violate Cross-Origin Resource Sharing (CORS).
        extraHeaders
    }

    @ChromeMinVersion(44)
    enum class OnBeforeRequestOptions {
        // Specifies the request is blocked until the callback function returns.
        blocking,

        // Specifies that the request body should be included in the event.
        requestBody,

        // Specifies that headers can violate Cross-Origin Resource Sharing (CORS).
        extraHeaders
    }

    @ChromeMinVersion(44)
    enum class OnBeforeSendHeadersOptions {
        // Specifies that the request header should be included in the event.
        request_headers,

        // Specifies the request is blocked until the callback function returns.
        blocking,

        // Specifies that headers can violate Cross-Origin Resource Sharing (CORS).
        extraHeaders
    }

    @ChromeMinVersion(44)
    enum class OnCompletedOptions {
        // Specifies that the response headers should be included in the event.
        responseHeaders,

        // Specifies that headers can violate Cross-Origin Resource Sharing (CORS).
        extraHeaders
    }

    @ChromeMinVersion(79)
    enum class OnErrorOccurredOptions {
        extraHeaders
    }

    @ChromeMinVersion(44)
    enum class OnHeadersReceivedOptions {
        // Specifies the request is blocked until the callback function returns.
        blocking,

        // Specifies that the request body should be included in the event.
        requestBody,

        // Specifies that headers can violate Cross-Origin Resource Sharing (CORS).
        extraHeaders
    }

    @ChromeMinVersion(44)
    enum class OnResponseStartedOptions {
        // Specifies that the response headers should be included in the event.
        responseHeaders,

        // Specifies that headers can violate Cross-Origin Resource Sharing (CORS).
        extraHeaders
    }

    @ChromeMinVersion(44)
    enum class OnSendHeadersOptions {
        // Specifies that the request header should be included in the event.
        request_headers,


        // Specifies that headers can violate Cross-Origin Resource Sharing (CORS).
        extraHeaders
    }

    // An object describing filters to apply to webRequest events.
    data class RequestFilter(
        var tabId: Number?,
        // A list of request types. Requests that cannot match any of the types will be filtered out.
        var types: List<ResourceType>?,
        // A list of URLs or URL patterns. Requests that cannot match any of the URLs will be filtered out.
        var urls: List<String>,
        var windowId: Number?,
    )

    @ChromeMinVersion(44)
    enum class ResourceType {
        // Specifies the resource as the main frame.
        main_frame,

        // Specifies the resource as a sub frame.
        sub_frame,

        // Specifies the resource as a stylesheet.
        stylesheet,

        // Specifies the resource as a script.
        script,

        // Specifies the resource as an image.
        image,

        // Specifies the resource as a font.
        font,

        // Specifies the resource as an object.
        object_,

        // Specifies the resource as an XMLHttpRequest.
        xmlhttprequest,

        // Specifies the resource as a ping.
        ping,

        // Specifies the resource as a Content Security Policy (CSP) report.
        csp_report,

        // Specifies the resource as a media object.
        media,

        // Specifies the resource as a WebSocket.
        websocket,

        // Specifies the resource as a WebBundle.
        webbundle,

        // Specifies the resource as a type not included in the listed types.
        other
    }

    // Contains data uploaded in a URL request.
    data class UploadData(
        // An ArrayBuffer with a copy of the data.
        var bytes: Any?,
        // A string with the file's path and name.
        var file: String?,
    )

    data class ActionIgnoredEventDetails(
        // The proposed action which was ignored.
        var action: IgnoredActionType,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
    )

    data class AuthRequiredEventDetails(
        // The server requesting authentication.
        var challenger: Challenger,
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // True for Proxy-Authenticate, false for WWW-Authenticate.
        var isProxy: Boolean,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // The authentication realm provided by the server, if there is one.
        var realm: String?,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The HTTP response headers that were received along with this response.
        var responseHeaders: List<Header>?,
        // The authentication scheme, e.g. Basic or Digest.
        var scheme: String,
        // Standard HTTP status code returned by the server.
        @ChromeMinVersion(43)
        var statusCode: Number,
        // HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.
        var statusLine: String,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )

    data class Challenger(
        var host: String,
        var port: Number
    )

    data class BeforeRedirectEventDetails(
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // Indicates if this response was fetched from disk cache.
        var fromCache: Boolean,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
        var ip: String?,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // The new URL.
        var redirectUrl: String,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The HTTP response headers that were received along with this redirect.
        var responseHeaders: List<Header>?,
        // Standard HTTP status code returned by the server.
        var statusCode: Number,
        // HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.
        var statusLine: String,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )

    data class BeforeRequestEventDetails(
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // Contains the HTTP request body data. Only provided if extraInfoSpec contains 'requestBody'.
        var requestBody: RequestBody?,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )

    data class RequestBody(
        // Errors when obtaining request body data.
        var error: String?,
        // If the request method is POST and the body is a sequence of key-value pairs encoded in UTF8, encoded as either multipart/form-data, or application/x-www-form-urlencoded, this dictionary is present and for each key contains the list of all values for that key. If the data is of another media type, or if it is malformed, the dictionary is not present. An example value of this dictionary is {'key': ['value1', 'value2']}.
        var formData: Any?,
        // If the request method is PUT or POST, and the body is not already parsed in formData, then the unparsed request body elements are contained in this array.
        var raw: List<UploadData>?,
    )

    data class BeforeSendEventDetails(
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // Indicates if this response was fetched from disk cache.
        var fromCache: Boolean,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The HTTP request headers that are going to be sent out with this request.
        var requestHeaders: List<Header>?,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )

    data class CompletedEventDetails(
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // Indicates if this response was fetched from disk cache.
        var fromCache: Boolean,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
        var ip: String?,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The HTTP response headers that were received along with this redirect.
        var responseHeaders: List<Header>?,
        // Standard HTTP status code returned by the server.
        var statusCode: Number,
        // HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.
        var statusLine: String,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )

    data class ErrorOccurredEventDetails(
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The error description. This string is not guaranteed to remain backwards compatible between releases. You must not parse and act based upon its content.
        var error: String,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // Indicates if this response was fetched from disk cache.
        var fromCache: Boolean,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
        var ip: String?,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )

    data class HeadersReceivedEventDetails(
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The HTTP response headers that were received along with this redirect.
        var responseHeaders: List<Header>?,
        // Standard HTTP status code returned by the server.
        @ChromeMinVersion(43)
        var statusCode: Number,
        // HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.
        var statusLine: String,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )

    data class ResponseStartedEventDetails(
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // Indicates if this response was fetched from disk cache.
        var fromCache: Boolean,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // The server IP address that the request was actually sent to. Note that it may be a literal IPv6 address.
        var ip: String?,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The HTTP response headers that were received along with this redirect.
        var responseHeaders: List<Header>?,
        // Standard HTTP status code returned by the server.
        var statusCode: Number,
        // HTTP status line of the response or the 'HTTP/0.9 200 OK' string for HTTP/0.9 responses (i.e., responses that lack a status line) or an empty string if there are no headers.
        var statusLine: String,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )

    data class SendHeadersEventDetails(
        // The UUID of the document making the request.
        @ChromeMinVersion(106)
        var documentId: String,
        // The lifecycle the document is in.
        @ChromeMinVersion(106)
        var documentLifecycle: ExtensionTypes.DocumentLifecycle,
        // The ID of the frame. 0 indicates that this is the main frame; a positive value indicates the ID of a subframe.
        var frameId: Number,
        // The type of frame the navigation occurred in.
        @ChromeMinVersion(106)
        var frameType: ExtensionTypes.FrameType,
        // The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.
        @ChromeMinVersion(63)
        var initiator: String?,
        // Standard HTTP method.
        var method: String,
        // A UUID of the parent document owning this frame. This is not set if there is no parent.
        @ChromeMinVersion(106)
        var parentDocumentId: String?,
        // The ID of the parent frame, or -1 if this is the main frame.
        var parentFrameId: Number,
        // The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request.
        var requestId: String,
        // The HTTP request headers that have been sent out with this request.
        var requestHeaders: List<Header>?,
        // The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab.
        var tabId: Number,
        // The time when this signal is triggered, in milliseconds since the epoch.
        var timeStamp: Number,
        // How the requested resource will be used.
        var type: ResourceType,
        var url: String,
    )
}

